package editor
{
	import Classes.pi_events;
	
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public class pi_userAvatar extends pi_previewItem {
		
		public function pi_userAvatar(index: int, parent:uif_component, ax:int=0, ay:int=0, 
									awidth:int=0, aheight:int=0, userData: *=null, styleClass:String='') {
			super(index, parent, ax, ay, awidth, aheight, userData, styleClass);
			var inner: Rectangle = getInner();
			_prevImage.height = inner.height - 20;
			if (_dataItem != null) _prevImage.loadSource(_dataItem.pic);
			(new uif_label(this, inner.x, inner.y + _prevImage.height, inner.width, 30, 'userAvatar')).text = pi_app.userName(_dataItem);
			addEvent(MouseEvent.ROLL_OVER, function(e: Event): void {
				dispatchEvent(new Event(pi_events.USERFOCUS, true, true));
			});
			addEvent(MouseEvent.ROLL_OUT, function(e: Event): void {
				dispatchEvent(new Event(pi_events.USERUNFOCUS, true, true));
			});
			
			if (_dataItem != null) _prevImage.disable = !userData.app_installed;
		}
		
		override protected function checkItemSelect(item: Object): Boolean {
			return scrollArea.selectItem.object.pic == item.pic;
		}
	}
}